<template>
	<view class=" page_wrap" style="height: 100vh;">

		<uv-swiper :list="list" height="260"></uv-swiper>
		<view class="good_detail_wrap z-flex-col z-row-center">
			<view class="price">
				<text style="margin-right: 10rpx;">¥</text>
				<text style="font-size: 42rpx;">{{goodDetail.coursePrice}}</text>
			</view>
			<view class="name z-flex z-col-center">
				<view class="type_item">
					{{goodDetail.courseType}}
				</view>
				<view class="">
					【{{goodDetail.classType}}】{{goodDetail.courseName}}
				</view>
			</view>
			<view class="message_item" v-if="goodDetail.courseAddress">
				{{goodDetail.courseAddress}}
			</view>
			<view class="message_item">
				{{goodDetail.courseStartDate}}至{{goodDetail.courseEndDate}}&nbsp;·&nbsp;{{goodDetail.courseTime}}{{goodDetail.courseStartTime}}-{{goodDetail.courseEndTime}}
			</view>
		</view>
		<view class="gap">

		</view>
		<view class="intro_wrap u-p-30">
			<uv-parse :content='goodDetail.productIntroduction'></uv-parse>
		</view>
		<view class="_footer">

		</view>
		<view class="bottom_wrap z-flex-col z-row-center" style="background: #fff;">
			<view class="bottom_item z-flex z-row-between z-col-center">
				<view class="icon_wrap z-flex">
					<view class="icon_item z-flex-col z-col-center z-row-center" style="margin-left: 34rpx;">
						<view class="u-m-t-6">
							<uv-image width="32rpx" height="32rpx" :fade="false"
								src="https://kjgcloud.hstm.org.cn/ticket-oss//hnkjg/5a61fb76e9a04756981d78fee36836ed.png">
							</uv-image>
						</view>
						<view class="" style="margin-top: 8rpx;">
							分享
						</view>
					</view>
					<view class="icon_item z-flex-col z-col-center z-row-center" style="margin-left: 28rpx;">
						<view class="" @click="toCart">
							<uv-image width="44rpx" height="44rpx" :fade="false"
								src="https://kjgcloud.hstm.org.cn/ticket-oss//hnkjg/ed9d036885f24a93bed7cf2ba66bbc4b.png">
							</uv-image>
						</view>
						<view class="" style="margin-top: 2rpx;">
							购物车
						</view>
					</view>
				</view>
				<view class="button_wrap">
					<MyButton type='warning' size="normal" text="前往报名" @click="toAddCart"></MyButton>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		getCourseDetail,
		orderConfirm,
		orderSubmit
	} from "@/api/shop/index.js"
	import {
		setCartList
	} from "@/utils/storage.js"
	import paymentMixin from "@/pages/payment/payment-mixin.js"
	export default {
		mixins: [paymentMixin],
		data() {
			return {
				goodDetail: {
					salePrice: 0
				},
				num: 1, //购物车数量
			}
		},

		onLoad(options) {
			if (options.id) {
				this.initPage(options.id)
			}
		},
		methods: {
			initPage(courseId) {
				getCourseDetail({
					courseId
				}).then(res => {
					if (res.data) {
						this.goodDetail = uni.$uv.deepClone(res.data)
					}
				})
			},

			toCart() {
				uni.navigateTo({
					url: '/packageA/pages/shop-goods/cart'
				})
			},
			toAddCart() {
				let cartList = getApp().globalData.cartList
				// let cartList = []
				console.log(cartList, "cartList")
				let offset = cartList.some(e => {
					if (e.prodId == this.goodDetail.id) {
						e.prodCount++
					}
					return e.prodId == this.goodDetail.id
				})
				if (!offset) {
					cartList.push({
						prodId: this.goodDetail.id,
						prodCount: 1,
						courseDO: this.goodDetail
					})
				}
				setCartList(cartList)
				getApp().globalData.cartList = uni.$uv.deepClone(cartList)

				// this.startPayment({
				// 	params: {
				// 		orderItems:cartList
				// 	}
				// })
				this.$toast.tip('报名成功')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page_wrap {
		height: 100vh;
		overflow: auto;
		background: #fff;
	}

	.content_wrap {
		border-radius: 20rpx;
		background-color: #fff;
		overflow: hidden;
		padding: 0 32rpx;
		margin: 0 20rpx 32rpx;
	}

	.title_wrap {
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 600;
		color: #000000;
		line-height: 42rpx;
		margin-top: 36rpx;
		margin-bottom: 16rpx;
	}

	.good_detail_wrap {
		padding: 30rpx;
		background: #FFFFFF;

		.price {
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 600;
			color: #D32A2A;
			line-height: 33rpx;
			margin-bottom: 12rpx;
		}

		.name {
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #000;
			line-height: 50rpx;
		}
	}

	.gap {
		height: 22rpx;

		background: #F0F0F0;
	}

	._footer {
		height: 220rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

	}

	.bottom_wrap {
		.bottom_item {
			width: 100%;
		}

		width: 100%;
		bottom: 0;
		position: fixed;
		height: 220rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	.icon_wrap {
		.icon_item {
			overflow: hidden;
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			color: #474747;
			line-height: 34rpx;
		}
	}

	.button_wrap {
		margin-right: 38rpx;

		.button_item {
			width: 100%;
			font-size: 32rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			color: #FFFFFF;
			line-height: 86rpx;

			&_left {
				width: 192rpx;
				height: 86rpx;
				background: #222222;
				border-top-left-radius: 48rpx;
				border-bottom-left-radius: 48rpx;
			}

			&_right {
				width: 192rpx;
				height: 86rpx;
				border-top-right-radius: 48rpx;
				border-bottom-right-radius: 48rpx;
			}
		}
	}

	._good_detail_wrap {
		height: 884rpx;
		position: relative;
	}

	._good_detail_top {
		padding: 36rpx 16rpx;

		._name {
			font-size: 30rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #474747;
			line-height: 35rpx;
			margin-bottom: 42rpx;
		}

		._price {
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #D32A2A;
			line-height: 33rpx;
		}
	}

	.line_wrap {
		padding: 0 20rpx;

		.line {
			height: 2rpx;
			background: #f0f0f0;
		}
	}

	._good_detail_center {
		padding: 28rpx 44rpx;
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 600;
		color: #474747;
		line-height: 42rpx;

		.tip_item {
			padding: 7rpx 31rpx;
			font-size: 30rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			color: #474747;
			line-height: 42rpx;
			background: #ECECEC;
			border-radius: 8rpx;
			margin-bottom: 20rpx;
			margin-right: 20rpx;
			font-weight: 500;
		}

		._good_detail_center_title {
			margin-bottom: 20rpx;
		}

		.tip_item.active {
			background: #FFF5E8;

		}
	}

	.scroll_wrap {
		height: 250rpx;

	}

	.number_wrap {
		padding: 36rpx 42rpx;
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 600;
		color: #474747;
		line-height: 35rpx;
	}

	::v-deep .u-number-box__input {
		border: none !important;

	}

	._good_detail_bottom {
		width: 100%;
		position: absolute;
		bottom: 0rpx;

		&_item {}
	}

	.tips_group_title {
		margin-bottom: 20rpx;
	}

	.ball {

		border-radius: 40rpx;
		opacity: 0.7;
	}

	.type_item {
		padding: 6rpx;
		background-color: #FDA759;
		color: #fff;
		border-radius: 4rpx;
		font-size: 22rpx;
		line-height: 22rpx;
	}

	.message_item {
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 500;
		color: #aaa;
		line-height: 35rpx;
		margin-top: 10rpx;
	}
</style>
